<?php
	session_start();
	require("connect.php");
	$pName = $_REQUEST["txtpName"];
	$pImage = $_FILES["pImage"]["name"];
	$pAmount = $_REQUEST["txtpAmount"];
	$pWarranty = $_REQUEST["txtpWarranty"];
	$pDetail = $_REQUEST["txtpDetail"];
	$pPrice = $_REQUEST["txtpPrice"];
	$catID = $_REQUEST["slCatagory"] ;
	$subID = $_REQUEST["slSubplier"];
	$pStatus = $_REQUEST["txtpStatus"];
	$ptID = $_REQUEST["slPromotion"];
	$ck = mysql_query("select * from product where pName = '{$pName}'");
	if($num = mysql_num_rows($ck)>0)
	{
		$_SESSION['loithem']="Sản phẩm này đã tồn tại trong kho hàng! ";
		echo "<script>window.location='product_add.php';</script>";
	}
	else
	{
		$sqlInsert = "insert into product(pName,pImage,pAmount,pWarranty,pDetail,pPrice,catID,subID,pStatus,ptID) values('{$pName}','{$pImage}',{$pAmount},{$pWarranty},'{$pDetail}',{$pPrice},{$catID},{$subID},{$pStatus},{$ptID})";
		mysql_query($sqlInsert) or die ("Not excute command ".$sqlInsert);
		mysql_close();
		echo "<script>window.location='quanlysanpham.php';</script>";
	}
?>
